<?php

class orgs extends Controller
{
	
	private function orgindex ()
	{
		$data['title'] = new BufferedView('tmembersOrgs');	
		$model = new member();
		$orgid = $model->getMyOrgs($_SESSION['stud_no']);
		$orgno = count($orgid);
		if ($orgno > 0)
		{		
			$data['content'] = new BufferedView('membersOrgs',array(
			"organization" => $orgid
			) );
		}
		else
		{
			$data['content'] = new BufferedView('membersOrgs',
			"You dont have any Organizations" );
		}
		new View ("membersTemplate", $data);	
	
	}


	public function orgname ()
	{
		$this->session();

		if (isset($orgname))
		{

			$counter = 0;
			$model = new member();
			$orgid = $model->getMyOrgs($_SESSION['stud_no']);
			$model2 =  new organization();
			$getallorgs = $model2->getOrg();
			$orgno = count($getallorgs);

			foreach($getallorgs as $row) //allorgs
			{
				if($orgname === $row['name'])
				{
					foreach($orgid as $row2) //members orgs only 
					{
					
						if($orgname === $row2['name'])
						{
							$_SESSION['chekmem'] = true;
							$data['checkmem'] = $_SESSION['chekmem'];
							$data['orgname'] = $orgname;
							
							if(isset($feature))
							{
								if (!isset($id))
								{
									$id = 0;
								}
							}

							else
							{
								$feature = "index";
								$id = 0;
							}
							$this->orgfeature($feature,$id);
						}

					}

					if (!$_SESSION['chekmem'])
					{
					$_SESSION['chekmem'] = false;
					$data['checkmem'] = $_SESSION['chekmem'];
					$data['orgname'] = $orgname;
					}
				}

				else 
				{
					$counter++;
				}
			
			}

			if ($counter === $orgno )
			{
				$data['content'] = "Such course name doesn't exist.";
				
			}

			new View ("orgTemplate", $data);
		}

		else 
		{

			$this->orgindex();
		}
		
	}


	

	private function orgfeature ($feature, $id)
	{
		if ($feature === "activity" )
		{
		}

	}

}

